<?php
$panelSettings = Zend_Json::decode($this->panel->settings);
$align = $panelSettings['align'];

// get the unit price config
$unitConfig = new RM_UnitHospitalityPricesConfig();
$personsConfigs = $unitConfig->fetchByUnit($this->unit->id)->toArray();
foreach ($personsConfigs as $configItem) {
    if ((int)$configItem['unit_value']) {
        $data[$configItem['name']] = (int)$configItem['unit_value'];
    } else {
        $data[$configItem['name']] = (int)$configItem['default_value'];
    }
}

// get the catering(board) types available
$unitprices = new RM_UnitHospitalityPrices();
$boardTypes = $unitprices->getBoardTypes($this->unit->id)->toArray();

?>
<link rel="stylesheet" type="text/css" href="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/userdata/plugins/Hospitality/css/main.css" />

<div id="<?php echo $this->panel->getDivID() ?>">
    <div class="RM_unit_details_hospitality_container" style="text-align:<?php echo $panelSettings['align']; ?>">
        <fieldset><legend><?php echo $this->_translate->_('RM.Hospitality.Fields','HospitalityTitle');?></legend>
            <table border="0" cellpadding="5" cellspacing="5">
                <tbody><tr>
                        <td width="60%"><span class="RM_unit_hospitality_maxpersons_label"><?php echo RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('RM.Hospitality.Fields', 'MaxOccupancy'); ?></span></td>
                    <td>&nbsp;</td>
                        <td nowrap><span class="RM_unit_hospitality_maxpersons_value"><?php echo $data['max_occupancy']; ?></span></td>
                    </tr>
                    <tr>
                        <td width="60%"><span class="RM_unit_hospitality_label"><?php echo RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('RM.Hospitality.Fields', 'MaxAdult'); ?></span></td>
                        <td>&nbsp;</td>
                        <td nowrap>
                            <?php
                            for ($i = 1; $i <= (int)$data['max_adults']; $i++) {
                                echo '<img src="' . RM_Environment::getConnector()->getRootURL() . 'RM/userdata/plugins/Hospitality/images/adult.png" alt="Maximum Adults ' . $data['max_adults'] . '" border="0"/>';
                            }
                            ?>                        </td>
                    </tr>
                    <?php if ((int)$data['max_children']>0){?>
                    <tr>
                        <td width="60%"><span class="RM_unit_hospitality_label"><?php echo RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('RM.Hospitality.Fields', 'MaxChildren'); ?></span></td>
                        <td>&nbsp;</td>
                        <td nowrap>
                            <?php
                            for ($i = 1; $i <= (int)$data['max_children']; $i++) {
                                echo '<img src="' . RM_Environment::getConnector()->getRootURL() . 'RM/userdata/plugins/Hospitality/images/child.png" alt="Maximum Children ' . $data['max_children'] . '" border="0"/>';
                            }
                            ?>                        </td>
                    </tr>
                    <?php }
                    if ((int)$data['max_infants']>0){
                    ?>
                    <tr>
                        <td width="60%"><span class="RM_unit_hospitality_label"><?php echo RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('RM.Hospitality.Fields', 'MaxInfants'); ?></span></td>
                        <td>&nbsp;</td>
                        <td nowrap>
                            <?php
                            for ($i = 1; $i <= (int)$data['max_infants']; $i++) {
                                echo '<img src="' . RM_Environment::getConnector()->getRootURL() . 'RM/userdata/plugins/Hospitality/images/infant.png" alt="Maximum Infants ' . $data['max_infants'] . '" border="0"/>';
                            }
                            ?>                        </td>
                    </tr>
                    <?php } ?>
                    <tr>
                        <td width="60%"><span class="RM_unit_hospitality_label"><?php echo RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('RM.Hospitality.Fields', 'AccomTypesAvailable'); ?></span></td>
                        <td>&nbsp;</td>
                        <td nowrap>
                        <?php
                        foreach ($boardTypes as $board){
                            if ($board['board_type']=="fb"){
                                echo RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('RM.Hospitality.Fields', 'FullBoard')."<br/>";
                            }
                            if ($board['board_type']=="hb"){
                                echo RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('RM.Hospitality.Fields', 'HalfBoard')."<br/>";
                            }
                            if ($board['board_type']=="ai"){
                                echo RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('RM.Hospitality.Fields', 'AllInclusive')."<br/>";
                            }
                            if ($board['board_type']=="bb"){
                                echo RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('RM.Hospitality.Fields', 'BedandBreakfast')."<br/>";
                            }
                            if ($board['board_type']=="sc"){
                                echo RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN)->_('RM.Hospitality.Fields', 'SelfCatering')."<br/>";
                            }
                        }
                        ?>
                        </td>
                    </tr>
                </tbody>
          </table>
        </fieldset>
    </div>
</div>